Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved meshbuilder's mesh handling #37

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

lorycontixd
Copy link
Contributor

With this pull request, I suggest to move the mesh loading part inside of a context manager to ensure that the file is properly closed, but most importantly to avoid a bug from trimesh where a string can be passed to trimesh.load_mesh, but internally it requires a file-like object. This way, the mesh is instantly loaded using a file object.
Also, I added a logging warning from MeshBuilder when an empty mesh is loaded.

@diegoferigo diegoferigo self-requested a review May 21, 2024 13:19
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there.

src/rod/builder/primitives.py Outdated Show resolved Hide resolved
src/rod/builder/primitives.py Outdated Show resolved Hide resolved
tests/test_meshbuilder.py Outdated Show resolved Hide resolved
Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last minor change, then ready to merge.

@@ -74,20 +74,12 @@ def __post_init__(self) -> None:
AssertionError: If the scale is not a 3D vector.
TypeError: If the mesh_path is not a str or pathlib.Path.
"""
mesh_path = pathlib.Path(self.mesh_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last nit, this attribute could already be a pathlib.Path object:

Suggested change
mesh_path = pathlib.Path(self.mesh_path)
mesh_path = self.mesh_path if isinstance(self.mesh_path, pathlib.Path) else pathlib.Path(self.mesh_path)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e1a70b0.

Copy link
Member

@diegoferigo diegoferigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the suggestion @lorycontixd, merging. Thanks for the contribution!

@diegoferigo diegoferigo merged commit 75d7649 into ami-iit:main Jun 10, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants